using System;
using Orm;

namespace ormsamples {
	public class DeletePetShopData {
		private void DeleteData() {
			PersistentTransaction t = petshop.PetShopPersistentManager.Instance().GetSession().BeginTransaction();
			try {
				petshop.Pet lpetshopPet = petshop.PetFactory.LoadPetByQuery(null, null);
				lpetshopPet.Delete();
				petshop.Transaction lpetshopTransaction = petshop.TransactionFactory.LoadTransactionByQuery(null, null);
				lpetshopTransaction.Delete();
				petshop.Customer lpetshopCustomer = petshop.CustomerFactory.LoadCustomerByQuery(null, null);
				lpetshopCustomer.Delete();
				petshop.Staff lpetshopStaff = petshop.StaffFactory.LoadStaffByQuery(null, null);
				lpetshopStaff.Delete();
				t.Commit();
			}
			catch(Exception e) {
				t.RollBack();
				Console.WriteLine(e);
			}
			
		}
		
		[STAThread]
		public static void Main(string[] args) {
			DeletePetShopData deletePetShopData = new DeletePetShopData();
			try {
				deletePetShopData.DeleteData();
			}
			finally {
				petshop.PetShopPersistentManager.Instance().DisposePersistentManager();
			}
			
		}
		
	}
}

